package com.ecfront.test.dao;

import java.util.Iterator;
import java.util.List;
import java.util.Set;

import com.ecfront.dao.GoodsBrandDAO;
import com.ecfront.pojo.Goods;
import com.ecfront.pojo.GoodsBrand;
import com.ecfront.pojo.GoodsSort;

import junit.framework.TestCase;

public class testGoodsBrand extends TestCase {
	private static final GoodsBrandDAO goodsBrandDao = (GoodsBrandDAO)SpringUtilTest.getBean("GoodsBrandDAO");
	//保存测试�������
	public void testSave(){
		GoodsBrand goodsBrand = new GoodsBrand();
		goodsBrand.setName("阿迪达斯");
		goodsBrandDao.save(goodsBrand);
	}
	//更新测试���
	public void testUpdate(){
		GoodsBrand goodsBrand = new GoodsBrand();
		goodsBrand.setId(1);
		goodsBrand.setName("艾迪巴斯");
		goodsBrandDao.save(goodsBrand);
	}
	//根据ID得到商品品牌���ID�õ���ƷƷ��
	public void testFindById(){
		GoodsBrand goodsBrand = goodsBrandDao.findById(2);
		System.out.println(goodsBrand.getName());
		
		Set gs = goodsBrand.getGoodsSort();
		Iterator iter = gs.iterator();
		while(iter.hasNext()){
			GoodsSort gss = (GoodsSort)iter.next();
			System.out.println(gss.getName());
		}
		Set goodss = goodsBrand.getGoods();
		for(Iterator iters = goodss.iterator();iters.hasNext();){
			Goods goods = (Goods)iters.next();
			System.out.println(goods.getName());
		}
	}
	//得到所有品牌�õ�����Ʒ��
	public void testFindAll(){
		List list = goodsBrandDao.findAll();
		for(Iterator iter = list.iterator();iter.hasNext();){
			GoodsBrand goodsBrand = (GoodsBrand)iter.next();
			System.out.println(goodsBrand.getName());
		}
	}
	//根据品牌得到测试���Ʒ�Ƶõ�����
	public void testFindByName(){
		List list = goodsBrandDao.findByGbName("阿迪达斯");
		for(Iterator iter = list.iterator();iter.hasNext();){
			GoodsBrand goodsBrand = (GoodsBrand)iter.next();
			System.out.println(goodsBrand.getName());
		}
	}
	//删除测试
	public void testDel(){
		GoodsBrand goodsBrand = new GoodsBrand();
		goodsBrand.setId(1);
		goodsBrandDao.delete(goodsBrand);
	}
}
